<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>金字塔</title>
</head>
<body>
       <script>
           var n=prompt('请设置金子塔的层数：');
           n=parseFloat(n)&&Number(n);
           if(isNaN(n)){
               alert('金字塔的层数必须是纯数字');
           }
         for(var i=1;i<=n;i++){
             for(var j=1;j<=n-i;j++){
                document.write('&nbsp');
                 }
                 for(var k=1;k<=2*i-1;k++){
                     document.write("*");
                 }
                 document.write('<br>');
             }
       </script>
       <p><a href="第二章作业.html">返回</a></p>
        
</body>
</html>